/* 拓扑排序
* 1.概念:
    首先遍历所有点，将入度为零的点加入队列，然后依次遍历出队的点的所有临边，并将临点的入度-1，若为0则加入队列。
    最终队列中的顺序就是拓扑排序的顺序

* 本题: 
    模板题 
*/

#pragma GCC optimize("O1,O2,O3,Ofast")
#pragma GCC optimize("no-stack-protector,unroll-loops,fast-math,inline")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,ssse3")

#include <iostream>
#include <cstring>
#include <algorithm> 
#include <queue>
// #define ONLINE_GUDGE
using namespace std;
const int N = 110, M = N * N/2;

int n;
int h[N], hs[N], e[M], ne[M], idx;
int d[N];
queue<int> q;
vector<int> ans;

void AddEdge(int a, int b) // , int c)
{ e[idx] = b, ne[idx] = h[a], h[a] = idx ++;} // w[idx] = c, 

void TopSort()
{
    for(int u = 1; u <= n; u++)
        if(!d[u]) q.push(u);

    while(q.size())
    {
        auto u = q.front(); q.pop();
        ans.push_back(u);
        for(int i = h[u]; ~i; i = ne[i]){
            auto v = e[i];
            if(--d[v] == 0) q.push(v);
        }
    }
}

int main()
{

    #ifdef ONLINE_JUDGE

    #else
    freopen("./in.txt","r",stdin);
    #endif
    ios::sync_with_stdio(false);   
	cin.tie(0);
    
    cin >> n;
    memset(h, -1, sizeof h);

    for(int i = 1; i <= n; i++){
        int son;
        while(cin >> son, son){
            AddEdge(i, son);
            d[son]++;
        }
    }


    TopSort();

    for (int i = 0; i < ans.size(); i++)
    {
        cout << ans[i] << ' ';
    }
    cout << endl;
    return 0;
}